package com.dyypdadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyypdadmin.pojo.Users;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UsersDao extends BaseMapper<Users> {
    //微信用户注册
    @Insert("insert into users(username,phone,password,address) values (#{username},#{phone},#{password},#{address})")
    int addUser(@Param("username") String username,@Param("phone") String phone,@Param("password") String password,@Param("address") String address);
    //用户登录
    @Select("select * from users where username =#{username} and password =#{password}")
    Users getUserByUsernameAndPassword(@Param("username")String username,@Param("password") String password);

    //用户信息更新
    @Update("update users set username=#{username},phone=#{phone},password=#{password},address=#{address} where user_id=#{user_id}")
    int updateUserInfo(Users users);

    //通过用户名查询用户信息
    @Select("select * from users where username=#{username}")
    List<Users> getUserInfoByUsername(@Param("username")String username);

    //getUserCounts
    @Select("select count(*) from users")
    int getUserCounts();

    @Update("update users set password=#{password} where user_id=#{user_id}")
    int updatePwdByUserId(Users users);
}
